package com.rainbow.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rainbow.entity.Department;
import com.rainbow.mapper.DepartmentMapper;
import com.rainbow.service.DepartmentService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author rainbow
 **/
@Service
@Transactional
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements DepartmentService {

    @Override
    public int addDep(Department department) {
        department.setEnabled(true);
        baseMapper.addDep(department);
        return department.getResult();
    }

    @Override
    public int deleteDep(Long did) {
        Department department = new Department();
        department.setId(did);
        baseMapper.deleteDep(department);
        return department.getResult();
    }

    @Override
    public List<Department> getDepByPid(Long pid) {
        return baseMapper.getDepByPid(pid);
    }

    @Override
    public List<Department> getAllDeps() {
        return baseMapper.getAllDeps();
    }
}
